<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<meta name="viewport"
	content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<title>众筹活动支付</title>
<script src="javascript/jquery.min.js"></script>
<script src="javascript/function.js"></script>
<link rel="stylesheet" href="stylesheet/style_v1.1.css">
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<style>
.zhifuanniu {
	width: 100%;
	padding-top: 20px;
}

.zhifuanniu ul {
	width: 100%;
	display: inline-block;
}

.zhifuanniu ul li {
	width: 25%;
	float: left;
	text-align: center;
	padding-right: 5px;
	padding-left: 5px;
	font-size: 14px;
	height: 30px;
}

.zhifuanniu a {
	display: inline-block;
	border: 1px solid #ff5a39;
	color: #ff5a39;
	padding: 2px 8px;
	border-radius: 20px;
	height: 30px;
	line-height: 25px;
}

.zhifuanniu input {
	display: inline-block;
	width: 100%;
	border: 1px solid #ff5a39;
	color: #ff5a39;
	padding: 2px 8px;
	font-size: 14px;
	border-radius: 20px;
	height: 30px;
}
.ff{
    background-color: #ff5a39!important;
    color: #ffffff!important;
}
</style>
<body>
	<div class="header-title">
		<a href="javascript:void(0);" class="fanhui"> <img
			src="image/tick.png" alt="">
		</a>
		<p>支付详细信息</p>
	</div>
	<div class="con padding-top50 padding-bottom50">

		<div class="work-ms" style="text-align: left;">
<!-- 			<p class="name" id="activityname"></p> -->
			<p class="shuoming" ><img src="/zjf_img/zhongchouxiangqing.jpg" style="width:100%;height:auto"></img></p>
<!-- 			<p class="shuoming" id="activitycontent"></p> -->
				<div class="zhifuanniu">
				<ul>
					<li><a href="javascript:void(0);" id="50">￥50</a></li>
					<li><a href="javascript:void(0);" id="100">￥100</a></li>
					<li><a href="javascript:void(0);" id="200">￥200</a></li>
					<li><input type="number" placeholder="自定义" id="activitymoney">
					</li>
				</ul>
			</div>
			<!--         <p class="zfje">￥99.00元</p> -->
			<!--            <input type="number" class="inputs" placeholder="参与众筹金额" id="activitymoney" style="display:none;"> -->
			<div class="col-12 padding5" style=" padding-top: 20px;">
				<a href="javascript:void(0);" class="btn" onclick="activityPay();">确认支付</a>
			</div>
		</div>

	</div>
	<script>
var selectmoney=0;
var activityId='<%=request.getParameter("parms.activityId")%>';
        $(function(){
        	queryActivityDetail();
        	$('.zhifuanniu a').on('click',function(){
                $('.zhifuanniu a').removeClass('ff');
                $(this).addClass('ff');
                selectmoney= $(this).attr("id");
            });
        });
        function queryActivityDetail() {
        	var params = "parms.activityId=" + activityId;
    	$.ajax({
    				type : 'post',
    				url : 'cliffordAction!queryActivityDetail.action',
    				async : false,
   					data : params, // 传给action的参数
    				success : function(data) {
    					if (data.result == 1) {
    						if (data.resultData.size == '0') {
    							alert("未获取到众筹信息");
    						}else if (data.resultData.size == '1') {
    							var list = data.resultData.datalist;
//     							document.getElementById("activityname").innerHTML = list[0].zjfGoodsActivity.activityName;
//     							document.getElementById("activitycontent").innerHTML =list[0].zjfGoodsActivity.activityContent;
    						} else {
    							alert("众筹活动信息不正确，请联系客服人员");
    						}
    					} else {
    						alert(data.msg);
    					}
    				}
    			});
    }
        function activityPay(){
//     		var money="0.01";
			var money=selectmoney;
			if(selectmoney==0){
				money=$("#activitymoney").val();
	    		if(typeof(money)=="undefined" || money==0){
	    			alert("请输入参与众筹的金额");
	    			return ;
	    		}
			}
//     		alert(money);
        	if (isWeiXin()) {
        		var params="parms.activityId="+activityId+"&parms.price="+money;
    		 	$.ajax({
    		 		type : 'post',
    		 		url : 'weixinjson!makeWeixinActivity.action',
    		 		data : params, // 传给action的参数
    		 		async:false,
    		 		success : function(data) { 
    		 			if(data.msg=="true"){
    		 				if (typeof WeixinJSBridge == "undefined"){
    		 				   if( document.addEventListener ){
    		 				       document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
    		 				   }else if (document.attachEvent){
    		 				       document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
    		 				       document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
    		 				   }
    		 				}else{
    		 				   onBridgeReady(data);
    		 				}
    		 			}else{
    		 				alert(data.msg);
    		 			}
    		 		}
    		 	});
        	}else{
        		 alert("请在微信中打开!");
        	}
        }
    	  function onBridgeReady(data){
    		   WeixinJSBridge.invoke(
    		       'getBrandWCPayRequest', {
    		           "appId":data.resultData.config.weixin_appId,     //公众号名称，由商户传入     
    		           "timeStamp":data.resultData.config.timestamp,         //时间戳，自1970年以来的秒数     
    		           "nonceStr" : data.resultData.config.nonceStr, //随机串     
    		           "package": data.resultData.config.packageInfo,     
    		           "signType" : "MD5",         //微信签名方式：     
    		           "paySign" : data.resultData.config.signature //微信签名 
    		       },
    		       function(res){     
    		           if(res.err_msg == "get_brand_wcpay_request:ok" ) {
    	 	        	   alert("支付成功");
    	 	        	  location.href=document.referrer;
    		           } else{
    		        	   alert("支付失败");
//    	 	        	   alert(res.err_code+":"+res.err_desc+":"+res.err_msg +"支付失败");
    		           }
    		           
    		       }
    		   );  
    	}
    </script>
</body>
</html>